package com.kakaxi.mybilibili.adapter;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kakaxi.mybilibili.R;
import com.kakaxi.mybilibili.bean.HorizontalVideoItemBean;

import java.util.List;

/**
 * 排行榜适配器
 * Created by kakaxi on 16/11/25.
 */

public class FindRankRecyAdapter extends BaseQuickAdapter<HorizontalVideoItemBean, BaseViewHolder> {

    public FindRankRecyAdapter(List<HorizontalVideoItemBean> data) {
        super(R.layout.item_recy_find_rank, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, HorizontalVideoItemBean
            horizontalVideoItemBean) {
        baseViewHolder
                .setText(R.id.txt_find_rank_no, baseViewHolder.getLayoutPosition() + 1 + "")
                .setText(R.id.txt_common_horizontal_video_title, horizontalVideoItemBean.getTitle())
                .setText(R.id.txt_common_horizontal_video_name, horizontalVideoItemBean.getAuthor())
                .setText(R.id.txt_common_horizontal_video_play, horizontalVideoItemBean.getPlay())
                .setText(R.id.txt_common_horizontal_video_danmaku, horizontalVideoItemBean
                        .getVideoReview());
        Glide.with(mContext).load(horizontalVideoItemBean.getPic()).crossFade().into
                ((ImageView) baseViewHolder.getView(R.id.img_common_horizontal_video_face));
    }

    @Override
    public void onAttachedToRecyclerView(RecyclerView recyclerView) {
        super.onAttachedToRecyclerView(recyclerView);
        if (recyclerView.getLayoutManager() == null) {
            recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
        }
    }
}
